﻿<!--
 Peter
 Created by: Peter Development Team
    http://peter.codeplex.com/
 
 GNU General Public License version 2 (GPLv2)
    http://peter.codeplex.com/license
 
 This code is provided on an AS IS basis, with no WARRANTIES,
 CONDITIONS or GUARANTEES of any kind.
-->
<ResourceDictionary x:Class="Peter.Themes.Default"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
                    xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
                    xmlns:controls="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
                    xmlns:utilities="clr-namespace:Peter.Common.Utilities;assembly=Peter.Common"
                    xmlns:mainmenu="clr-namespace:Peter.Common.MainMenu;assembly=Peter.Common"
                    xmlns:bindingConverters="clr-namespace:Peter.Common.BindingConverters;assembly=Peter.Common">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="BaseSkin.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <SolidColorBrush x:Key="BaseBackground"
                     Color="#D8D8D9" />
    <SolidColorBrush x:Key="HighlightBackground"
                     Color="#EBEBEB" />
    <SolidColorBrush x:Key="FocusedBackground"
                     Color="#C0C0C0" />
    <SolidColorBrush x:Key="SelectedBackground"
                     Color="#858585" />

    <SolidColorBrush x:Key="DisabledForeground"
                     Color="#AAAAAA" />

    <Style TargetType="{x:Type xcad:DockingManager}">
        <Setter Property="Background"
                Value="{StaticResource BaseBackground}" />
    </Style>

    <Style TargetType="Window">
        <Setter Property="Background"
                Value="{StaticResource BaseBackground}" />
    </Style>

    <Style TargetType="StatusBar">
        <Setter Property="Background"
                Value="{StaticResource BaseBackground}" />
    </Style>

    <ControlTemplate TargetType="Button"
                     x:Key="MainMenuButtonTemplate">
        <Border x:Name="PART_Border"
                BorderThickness="0">
            <ContentPresenter Content="{TemplateBinding Content}" />
        </Border>

        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver"
                     Value="True">
                <Setter TargetName="PART_Border"
                        Property="Background"
                        Value="{StaticResource HighlightBackground}" />
            </Trigger>

            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver"
                               Value="True" />
                    <Condition Property="IsFocused"
                               Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="PART_Border"
                            Property="Background"
                            Value="{StaticResource FocusedBackground}" />
                </MultiTrigger.Setters>
            </MultiTrigger>

            <Trigger Property="IsEnabled"
                     Value="False">
                <Setter Property="Foreground"
                        Value="{StaticResource DisabledForeground}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type mainmenu:MainMenu}">
        <Setter Property="Background"
                Value="{StaticResource BaseBackground}" />
    </Style>

    <Style x:Key="MainMenuSeparatorStyle">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="mainmenu:MainMenuItem">
                    <Border BorderThickness="2,0,0,0"
                            Margin="0,3"
                            BorderBrush="{StaticResource HighlightBackground}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MainMenuTextBoxStyle">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="mainmenu:MainMenuItem">
                    <StackPanel Orientation="Horizontal">
                        <icons:IconDisplay Icon="{Binding Path=Icon}"
                                           x:Name="_iconDisplay"
                                           Margin="0,0,4,0"
                                           IconSize="Medium" />
                        <controls:CommandTextBox Text="{Binding Path=Text, UpdateSourceTrigger=PropertyChanged}"
                                                 KeyPressCommand="{Binding Path=KeyCommand}"
                                                 PlaceHolderText="{Binding Path=Title}"
                                                 Command="{Binding Path=Command}"
                                                 Width="{Binding Path=Width}"
                                                 CaretPosition="{Binding Path=CaretPosition}"
                                                 Height="21"
                                                 utilities:FocusExtension.IsFocused="{Binding Path=IsFocused}"
                                                 utilities:FocusExtension.FocusEvents="{Binding Path=FocusCommand}"
                                                 VerticalAlignment="Center"
                                                 VerticalContentAlignment="Center"
                                                 CommandParameter="{Binding Path=CommandParameter}" />
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding Path=Icon}"
                                     Value="None">
                            <Setter TargetName="_iconDisplay"
                                    Property="Visibility"
                                    Value="Collapsed" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MainMenuDropDownItemStyle"
           TargetType="{x:Type MenuItem}">
        <Setter Property="ToolTip"
                Value="{Binding Path=ToolTip}" />
        <Setter Property="Command"
                Value="{Binding Path=Command}" />
        <Setter Property="CommandParameter"
                Value="{Binding Path=CommandParameter}" />
        <Setter Property="ItemsSource"
                Value="{Binding Path=Children}" />
        <Setter Property="Header"
                Value="{Binding Path=Title}" />
        <Setter Property="Visibility"
                Value="{Binding Path=IsVisible, Converter={StaticResource _BoolToVisi}}" />
        <Setter Property="Icon"
                Value="{Binding Path=Icon, Converter={StaticResource _IconDisplay}}" />
        <Setter Property="ItemContainerStyleSelector"
                Value="{StaticResource _MenuItemStyleSelector}" />
    </Style>

    <Style x:Key="MainMenuItemQaStyle">
        <Setter Property="Control.Template"
                Value="{StaticResource MainMenuButtonTemplate}" />
    </Style>

    <Style x:Key="MainMenuItemButtonStyle">
        <Setter Property="Control.Template"
                Value="{StaticResource MainMenuButtonTemplate}" />
    </Style>

    <Style x:Key="MainMenuItemDropDownStyle">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">

                    <Border x:Name="PART_Border">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Border Grid.Column="0"
                                    BorderBrush="Black"
                                    Margin="0,6"
                                    BorderThickness="{TemplateBinding BorderThickness}" />
                            <icons:IconDisplay Icon="ChevronDown"
                                               Grid.Column="1"
                                               Padding="4,0" />
                        </Grid>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"
                                 Value="True">
                            <Setter TargetName="PART_Border"
                                    Property="Background"
                                    Value="{StaticResource HighlightBackground}" />
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver"
                                           Value="True" />
                                <Condition Property="IsFocused"
                                           Value="True" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="PART_Border"
                                        Property="Background"
                                        Value="{StaticResource FocusedBackground}" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>

                        <Trigger Property="IsEnabled"
                                 Value="False">
                            <Setter Property="Foreground"
                                    Value="{StaticResource DisabledForeground}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MainMenuContentAreaStyle">
        <Setter Property="Control.Margin"
                Value="0" />
        <Setter Property="Control.Background"
                Value="{StaticResource SelectedBackground}" />
    </Style>

    <Style TargetType="{x:Type mainmenu:MainMenuHeader}">
        <Setter Property="IsSelected"
                Value="{Binding Path=IsSelected}" />
        <Setter Property="IsEnabled"
                Value="{Binding Path=IsEnabled}" />
        <Setter Property="ToolTip"
                Value="{Binding Path=ToolTip}" />
        <Setter Property="Visibility"
                Value="{Binding Path=IsVisible, Converter={StaticResource _BoolToVisi}}" />
        <Setter Property="IsTabStop"
                Value="False" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type mainmenu:MainMenuHeader}">
                    <Border BorderThickness="0"
                            Focusable="False"
                            Margin="0"
                            Height="30"
                            Padding="7,0"
                            x:Name="PART_Border">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>

                            <icons:IconDisplay HorizontalAlignment="Center"
                                               VerticalAlignment="Center"
                                               IconSize="{Binding Path=HeaderIconSize, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type mainmenu:MainMenu}}}"
                                               x:Name="PART_Icon"
                                               Grid.Column="0"
                                               Icon="{Binding Path=Icon}" />

                            <TextBlock Grid.Column="1"
                                       Focusable="False"
                                       HorizontalAlignment="Center"
                                       VerticalAlignment="Center"
                                       Name="PART_Title"
                                       Margin="5,0"
                                       FontSize="12"
                                       TextTrimming="CharacterEllipsis"
                                       Text="{Binding Path=Title}" />

                            <Button x:Name="PART_DropDown"
                                    Grid.Column="2"
                                    BorderThickness="0"
                                    VerticalContentAlignment="Center"
                                    HorizontalContentAlignment="Center"
                                    Style="{DynamicResource MainMenuItemDropDownStyle}">
                                <Button.ContextMenu>
                                    <ContextMenu ItemsSource="{Binding Path=MenuItems}"
                                                 ItemContainerStyleSelector="{StaticResource _MenuItemStyleSelector}" />
                                </Button.ContextMenu>
                            </Button>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>

                        <DataTrigger Binding="{Binding Path=IsSelected}"
                                     Value="True">
                            <Setter TargetName="PART_Border"
                                    Property="Background"
                                    Value="{StaticResource SelectedBackground}" />
                            <Setter TargetName="PART_Title"
                                    Property="FontWeight"
                                    Value="Bold" />
                        </DataTrigger>

                        <DataTrigger Binding="{Binding Path=MenuItems}"
                                     Value="{x:Null}">
                            <Setter TargetName="PART_DropDown"
                                    Property="Visibility"
                                    Value="Collapsed" />
                        </DataTrigger>

                        <DataTrigger Binding="{Binding Path=MenuItems.Count}"
                                     Value="0">
                            <Setter TargetName="PART_DropDown"
                                    Property="Visibility"
                                    Value="Collapsed" />
                        </DataTrigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <SolidColorBrush x:Key="_GlyphBrush" Color="#444" />

    <!--=================================================================
     TreeViewItem
  ==================================================================-->
    <Style x:Key="ExpandCollapseToggleStyle" TargetType="ToggleButton">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid
                        Width="15"
                        Height="13"
                        Background="Transparent">
                        <Path x:Name="ExpandPath"
                              HorizontalAlignment="Left"
                              VerticalAlignment="Center"
                              Margin="1,1,1,1"
                              Fill="{StaticResource _GlyphBrush}"
                              Data="M 4 0 L 8 4 L 4 8 Z" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked"
                                 Value="True">
                            <Setter Property="Data"
                                    TargetName="ExpandPath"
                                    Value="M 0 4 L 8 4 L 4 8 Z" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="TreeViewItemFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Border>
                        <Rectangle Margin="0,0,0,0"
                                   StrokeThickness="5"
                                   Stroke="Black"
                                   StrokeDashArray="1 2"
                                   Opacity="0" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style x:Key="{x:Type TreeViewItem}"
           TargetType="{x:Type TreeViewItem}">
        <Setter Property="Background"
                Value="Transparent" />
        <Setter Property="HorizontalContentAlignment"
                Value="{Binding Path=HorizontalContentAlignment,
              RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="VerticalContentAlignment"
                Value="{Binding Path=VerticalContentAlignment,
              RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
        <Setter Property="Padding"
                Value="1,0,0,0" />
        <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
        <Setter Property="FocusVisualStyle"
                Value="{StaticResource TreeViewItemFocusVisual}" />
        <Setter Property="IsExpanded"
                Value="{Binding IsExpanded, Mode=TwoWay}" />
        <Setter Property="IsSelected"
                Value="{Binding IsSelected, Mode=TwoWay}" />
        <Setter Property="utilities:TreeViewItemBehavior.IsBroughtIntoViewWhenSelected"
                Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeViewItem}">
                    <ControlTemplate.Resources>
                        <bindingConverters:LeftMarginMultiplierConverter Length="19" x:Key="LengthConverter" />
                    </ControlTemplate.Resources>
                    <StackPanel>
                        <Border Name="Bd"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Padding="{TemplateBinding Padding}">
                            <Grid
                                Margin="{Binding Converter={StaticResource LengthConverter},
                              RelativeSource={RelativeSource TemplatedParent}}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="19" />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <ToggleButton x:Name="Expander"
                                              Style="{StaticResource ExpandCollapseToggleStyle}"
                                              IsChecked="{Binding Path=IsExpanded,
                              RelativeSource={RelativeSource TemplatedParent}}"
                                              ClickMode="Press" />

                                <ContentPresenter x:Name="PART_Header"
                                                  Grid.Column="1"
                                                  ContentSource="Header"
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                            </Grid>
                        </Border>
                        <ItemsPresenter x:Name="ItemsHost" />
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded"
                                 Value="false">
                            <Setter TargetName="ItemsHost"
                                    Property="Visibility"
                                    Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="HasItems"
                                 Value="false">
                            <Setter TargetName="Expander"
                                    Property="Visibility"
                                    Value="Hidden" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="HasHeader"
                                           Value="false" />
                                <Condition Property="Width"
                                           Value="Auto" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_Header"
                                    Property="MinWidth"
                                    Value="75" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="HasHeader"
                                           Value="false" />
                                <Condition Property="Height"
                                           Value="Auto" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="PART_Header"
                                    Property="MinHeight"
                                    Value="19" />
                        </MultiTrigger>
                        <Trigger Property="IsSelected"
                                 Value="true">
                            <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected"
                                           Value="true" />
                                <Condition Property="IsSelectionActive"
                                           Value="false" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="Bd"
                                    Property="Background"
                                    Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
                        </MultiTrigger>
                        <Trigger Property="IsEnabled"
                                 Value="false">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>